import pandas as pd
# 学习pandas中的常用操作01
# data = {'name':['aa','bb','cc'],'age':[10,20,30],'year':[2017,2018,2019]}

# df = pd.DataFrame(data,index=['a','b','c'])

# df['test1'] = pd.Series(['a1','b1','c1'],['a','b','c'])
# df['test2'] = df['age'] + df['year']
# df = df.drop('age', axis=1)
# df = df.drop('c', axis=0)
# print(type(df['name']))
# print(type(df[['name','age']]))
# df.drop('age', axis=1, inplace=True)
# df.drop('a', axis=0, inplace=True)
# df.reset_index(inplace=True)
# print(df.loc[['a','c'],['name']])
# print(df[df['age'] > 10][['name','year']])

# df['ID'] = ['id1','id2','id3']
# df.set_index('ID',inplace=True)

# print(df.head(1))
# print(df.tail(1))
# print(df.columns)
# print(dir(df))
# print(df.describe())
# print(df.columns)
# print(df.mean())
# print(df.min())
# print(list('abcd'))

# df.to_excel('foo.xlsx')
# print(df)
# df.sort_values(by='year',inplace=True,ascending=False)
# for i in df.index:
#     df['year'] = df['year'].at[i]+2
# print(df)
# print(df.groupby('name').mean())
# print(df.mean())

df = pd.read_excel('test.xlsx',index_col='ID')
# df.sort_values(by=['price'], inplace=True,ascending=False)
print(df.head(2))
df['price'] = df['price'].apply(lambda x:x+2)
print(df.head(2))
df.sort_values(by=['wedy','price'], inplace=True,ascending=[True,False])
df['total prices'] = df['price'] * df['discount']
# df.to_excel('ee.xlsx')
# print('Done!')
print(df.head(2))